// 导入模块
import mysql from "mysql2/promise";

async function initDataBase(): Promise<mysql.Connection> {
	// 创建一个数据库连接
	const connection = await mysql.createConnection({
		host: "118.31.39.238",
		user: "dhx",
		password: "556688",
		port: 3307,
		database: "my_world",
	});

	connection.connect().catch((err) => {
		if (err) throw err;
		console.error("数据库连接失败：", err);
	});
	return connection;
}

export default initDataBase();
